/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#pragma once

#include <Ogre.h>
#include <string>

#include "../XSystemComponents\XOgre\OgreRenderer.h"
#include "../XFrameworkTypedefsAndDefines.h"
#include <vector>

namespace XF
{
	class QuickAndDirtyOgreDebugRenderer
	{
	private:
		int mId;
		static int smNextId;

		static QuickAndDirtyOgreDebugRenderer* mSingletonInstance;

		float mY;
		XF::OgreRenderer *mRenderer;

		Ogre::SceneNode* mNode;
		Ogre::ManualObject* mManObj;
		std::string mMaterialString;

		Ogre::Vector4 mColor;
		bool mColourAllowdToChange;

		void DrawRectFilled(const XF::Vector2 &min, const XF::Vector2 &max){DrawRectFilled(min.x, max.x, min.y, max.y);}
		void DrawRectFilled(float x1, float x2, float y1, float y2);
		void DrawTriangleFilled(const XF::Vector2 &p1, const XF::Vector2 &p2, const XF::Vector2 &p3);
		void DrawCircleFilled(const XF::Vector2 &center, float radius, int smoothFactor = 16);	
		void DrawCircleFilled( const XF::Vector3 &center, float radius, int smoothFactor = 16 );
		
	public:
		QuickAndDirtyOgreDebugRenderer(XF::OgreRenderer *renderer);
		~QuickAndDirtyOgreDebugRenderer();

		void Begin();
		void End();

		void DrawLine(const XF::Vector2 &p1, const XF::Vector2 &p2);
		void DrawLine( const XF::Vector3 &p1, const XF::Vector3 &p2 );//chris: for easier quick 3D postion circles
		void DrawLineStrip(std::vector<XF::Vector2> &lines);

		void DrawCircle(const XF::Vector2 &center, float radius, int smoothFactor = 16);
		void DrawCircle( const XF::Vector3 &center, float radius, int smoothFactor = 16 ); //chris: for easier quick 3D postion circles
		
		void DrawRect(const XF::Vector2 &min, const XF::Vector2 &max){DrawRect(min.x, max.x, min.y, max.y);}
		void DrawRect(float x1, float x2, float y1, float y2);

		void DrawTriangle(const XF::Vector2 &p1, const XF::Vector2 &p2, const XF::Vector2 &p3);

		void Color(const XF::Vector3 &color){Color(color.x, color.y, color.z);}
		void Color(const Ogre::Vector4 &color){Color(color.x, color.y, color.z, color.w);}
		void Color(float r, float g, float b, float a = 1.0f);

		float GetYPlane() const { return mY; }
		void SetYPlane(float val) { mY = val; }
		void Clear(); //chris

		static QuickAndDirtyOgreDebugRenderer* GetInstance();
		static void InitializeStaticVersion(XF::OgreRenderer *renderer);
		static void KillStaticVersion();
		void QuickAndDirtyOgreDebugRenderer::SetFill(bool fill);

		
		//void QuickAndDirtyOgreDebugRenderer::DrawCylinder( const XF::Vector2 &pos1,const XF::Vector2 &pos2 , float radius, int smoothFactor /*= 16*/ ) /*chris */;
		//chris:
		void QuickAndDirtyOgreDebugRenderer::DrawCylinder( const XF::Vector3 &pos1,const XF::Vector3 &pos2 , float radius, int smoothFactor /*= 16*/ ) /*chris */;
	};
}
#define DIRTY_RENDER XF::QuickAndDirtyOgreDebugRenderer::GetInstance()